Add sxpr function for installing a new type.
Signed-off-by: Mike Wray <mike.wray@hp.com>
/** Number of entries in the types array. */
static int type_sup = sizeof(types)/sizeof(types[0]);
+/** Define a type.
+ * The tydef must have a non-zero type code.
+ * It is an error if the type code is out of range or already defined.
+ *
+ * @param tydef type definition
+ * @return 0 on success, error code otherwise
+ */
+int def_sxpr_type(SxprType *tydef){
+ int err = 0;
+ int ty = tydef->type;
+ if(ty < 0 || ty >= type_sup){
+ err = -EINVAL;
+ goto exit;
+ }
+ if(types[ty].type){
+ err = -EEXIST;
+ goto exit;
+ }
+ types[ty] = *tydef;
+ exit:
+ return err;
+
+}
+
/** Get the type definition for a given type code.
*
* @param ty type code
} SxprType;
+extern int def_sxpr_type(SxprType *tydef);
extern SxprType *get_sxpr_type(int ty);
/** Free the pointer in an sxpr.